package com.gtl.meishi.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.gtl.meishi.R;
import com.gtl.meishi.bean.Collection;

import java.util.List;

/**
 * Created by zhangke on 16/7/11.
 */
public class CollectionAdapter extends BaseAdapter {

    private Context context;
    private List<Collection> listCollections;

    public CollectionAdapter(Context context, List<Collection> listCollections) {
        this.context = context;
        this.listCollections = listCollections;
    }

    @Override
    public int getCount() {
        return listCollections.size();
    }

    @Override
    public Object getItem(int i) {
        return listCollections.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        Holder holder=null;
        if (view==null){
            view= LayoutInflater.from(context).inflate(R.layout.collection_item,viewGroup,false);
            holder=new Holder(view);
            view.setTag(holder);
        }else {
            holder= (Holder) view.getTag();
        }
        Collection collection=listCollections.get(i);
      //  Picasso.with(context).load()
        holder.mTextView.setText(collection.getCaption());
        return view;
    }

    class  Holder{
        private  View view;
        private ImageView imageView;
        private TextView mTextView;

        public Holder(View view) {
            this.view = view;
            imageView= (ImageView) view.findViewById(R.id.imageview_collection_item);
            mTextView= (TextView) view.findViewById(R.id.textview_collection_item);
        }
    }



}
